<?php

/**
 * Persona form base class.
 *
 * @method Persona getObject() Returns the current form's model object
 *
 * @package    zing
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePersonaForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'nombre'          => new sfWidgetFormInputText(),
      'apellido'        => new sfWidgetFormInputText(),
      'tipoDoc'         => new sfWidgetFormChoice(array('choices' => array('LC' => 'LC', 'CIB' => 'CIB', 'CIC' => 'CIC', 'CIU' => 'CIU', 'RN' => 'RN', 'SD' => 'SD', 'LF' => 'LF', 'LE' => 'LE', 'DNI' => 'DNI', 'CI' => 'CI', 'PAS' => 'PAS', 'CRT' => 'CRT', 'LM' => 'LM', '--' => '--'))),
      'docNumero'       => new sfWidgetFormInputText(),
      'fechaNacimiento' => new sfWidgetFormDateTime(),
      'sexo'            => new sfWidgetFormChoice(array('choices' => array('F' => 'F', 'M' => 'M', 'O' => 'O'))),
      'activo'          => new sfWidgetFormInputCheckbox(),
      'cuil'            => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'nombre'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'apellido'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'tipoDoc'         => new sfValidatorChoice(array('choices' => array(0 => 'LC', 1 => 'CIB', 2 => 'CIC', 3 => 'CIU', 4 => 'RN', 5 => 'SD', 6 => 'LF', 7 => 'LE', 8 => 'DNI', 9 => 'CI', 10 => 'PAS', 11 => 'CRT', 12 => 'LM', 13 => '--'))),
      'docNumero'       => new sfValidatorInteger(),
      'fechaNacimiento' => new sfValidatorDateTime(array('required' => false)),
      'sexo'            => new sfValidatorChoice(array('choices' => array(0 => 'F', 1 => 'M', 2 => 'O'))),
      'activo'          => new sfValidatorBoolean(array('required' => false)),
      'cuil'            => new sfValidatorString(array('max_length' => 14)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Persona', 'column' => array('tipodoc', 'docnumero')))
    );

    $this->widgetSchema->setNameFormat('persona[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Persona';
  }

}
